<?php
/**
 * 作者：云喵软件开发工作室
 * 官网：https://www.meoyun.com
 */

namespace app\model;

class CommentsModel extends BaseModel
{
    protected $table = 'comments';

    public function user()
    {
        return $this->belongsTo(UsersModel::class, 'user_id');
    }

    public function to_user()
    {
        return $this->belongsTo(UsersModel::class, 'to_user_id');
    }

    public function post()
    {
        return $this->belongsTo(PostModel::class, 'post_id');
    }

    public function replies()
    {
        return $this->hasMany(CommentsModel::class, 'parent_id', 'id');
    }
}